﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xunit;
using M3G;

namespace MyTestProject {
    public class TestGraphics3D {

        [Fact]
        public void TestConstructor () {
            var g3d = Graphics3D.GetInstance ();
            var g3d1 = Graphics3D.GetInstance ();
            var g3d2 = Graphics3D.GetInstance ();

            Assert.NotNull (g3d);
            Assert.Same (g3d, g3d1);
            Assert.Same (g3d, g3d2);

            Assert.Equal (null, g3d.Target);
            Assert.Equal (0, g3d.RenderingFlags);
            Assert.Equal (0.0f, g3d.DepthRangeNear);
            Assert.Equal (1.0f, g3d.DepthRangeFar);
        }

        [Fact]
        public void TestSetViewport () {
            var g3d = Graphics3D.GetInstance ();
            g3d.SetViewport (1, 2, 100, 200);

            Assert.Equal (1, g3d.ViewportX);
            Assert.Equal (2, g3d.ViewportY);
            Assert.Equal (100, g3d.ViewportWidth);
            Assert.Equal (200, g3d.ViewportHeight);
        }

        [Fact]
        public void TestSetDepthRange () {
            var g3d = Graphics3D.GetInstance ();
            g3d.SetDepthRange (0.1f, 0.2f);

            Assert.Equal (0.1f, g3d.DepthRangeNear);
            Assert.Equal (0.2f, g3d.DepthRangeFar);
        }

        [Fact]
        public void TestBindTargetWithImage2D () {
            var g3d = Graphics3D.GetInstance ();
            var img = new Image2D (Image2D.RGB, 640, 480);

            var flags = Graphics3D.Antialias | Graphics3D.Dither | Graphics3D.TrueColor | Graphics3D.Overwite | Graphics3D.NoOverlays | Graphics3D.Pure3D | Graphics3D.Depth | Graphics3D.Stencil;
            g3d.BindTarget (img, flags);

            Assert.Equal (img, g3d.Target);
            Assert.Equal (flags, g3d.RenderingFlags);

            g3d.ReleaseTarget ();
        }


        [Fact (Skip = "未実装")]
        public void TestGetProperties () {
            var img = new Image2D (Image2D.RGB, 640, 480);
            var props = Graphics3D.GetProperties (img);

            // 省略
        }

 
    }

}
